package cmo.cel.entity;

import java.util.HashMap;
import java.util.Map;

import com.baidu.aip.imageclassify.AipImageClassify;
import com.cel.Service.WxService;

import cmo.cel.util.Util;
import net.sf.json.JSONObject;

public class CreateMenu {
		public static final String APP_ID = "17881810";
	    public static final String API_KEY = "bjOhgTfoLhIeKRoaNG9FFX7p";
	    public static final String SECRET_KEY = "Du1m9W0Ya2E0mpIKhgGNnvyh6ezdF9G2";

	public static void main(String[] args) {
		//菜单对象
		Button btn = new Button();
		//一级菜单
		btn.getButton().add(new ClickButton("点我听歌", "1"));
		//一级菜单,第二个
		btn.getButton().add(new ViewButton("点击进行搜索","http://www.baidu.com"));
		//一级菜单,三
		SubButton sb = new SubButton("菜单");
		sb.getSub_button().add(new PhotoOrAlbumButton("上传图片", "31"));
		sb.getSub_button().add(new ClickButton("你点我丫", "32"));
		sb.getSub_button().add(new ViewButton("新浪微博", "https://weibo.com"));
		sb.getSub_button().add(new ViewButton("网易新闻", "https://news.163.com"));
		//把上边的加入到第三个菜单
		btn.getButton().add(sb);
		//转json
		JSONObject jsonObject = JSONObject.fromObject(btn);
		//准备url
		String url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN";
		url = url.replace("ACCESS_TOKEN", WxService.getAccessToken());
		//发送请求
		String result = Util.post(url, jsonObject.toString());
		System.out.println(result);
		
		
//		//
//		
//		 // 初始化一个AipImageClassify
//        AipImageClassify client = new AipImageClassify(APP_ID, API_KEY, SECRET_KEY);
//
//        // 可选：设置网络连接参数
//        client.setConnectionTimeoutInMillis(2000);
//        client.setSocketTimeoutInMillis(60000);
//
//        // 可选：设置代理服务器地址, http和socket二选一，或者均不设置
////        client.setHttpProxy("proxy_host", proxy_port);  // 设置http代理
////        client.setSocketProxy("proxy_host", proxy_port);  // 设置socket代理
//
//        // 调用接口
//        String path = "/home/erlong/Pictures/2.png";
//        org.json.JSONObject res = client.objectDetect(path, new HashMap<String, String>());
//        System.out.println(res.toString(2));
//        
//    }
//	public void sample(AipImageClassify client) {
//	    // 传入可选参数调用接口
//	    HashMap<String, String> options = new HashMap<String, String>();
//	    options.put("baike_num", "5");
//	    
//	    // 参数为本地路径
//	    String image = "test.jpg";
//	    org.json.JSONObject res = client.advancedGeneral(image, options);
//	    System.out.println(res.toString(2));
//
//	    // 参数为二进制数组
////	    byte[] file = readFile("test.jpg");
////	    res = client.advancedGeneral(file, options);
////	    System.out.println(res.toString(2));
//	}
//
	}
}
